import {
	useMyStore
} from "../store"

import {
	resolve
} from "dns";

//1
export const getUserInfo = () => {
	return new Promise(resolve => {
		uni.getUserProfile({
			desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
			success: (res) => {
				resolve(res)
			}
		})
	})
}


//2 改接口后直走这一步
export const loginHandle = () => {
	return new Promise(resolve => {
		console.log('uni', uni);
		let myStore = useMyStore();
		if (myStore.openid) return;

		uni.login({
			success(res) {
				if (res.code) {
					resolve(res)
					//发起网络请求拿后端openid
				} else {
					console.log('登录失败！', res.errMsg)
				}
			}
		})
	})
}


